//package hut.utils
//
//import org.apache.commons.pool2.impl.GenericObjectPoolConfig
//import redis.clients.jedis.JedisPool
//
///**
// * @author chenjie
// * @date 2020/12/10 15:01
// */
//object RedisUtil {
//  private val redisHost: String = "localhost"
//  private val redisPort: Int = 6379
//  private val redisTimeOut: Int = 30000 // ms
//  private val maxTotal = 300
//  private val maxIdle = 100
//  private val minIdle = 1
//
//  @transient private var pool: JedisPool = _
//  makePool(redisHost,redisPort, redisTimeOut, maxTotal, maxIdle, minIdle)
//
//  def makePool(redisHost: String, redisPort: Int, redisTimeout: Int,
//               maxTotal: Int, maxIdle: Int, minIdle: Int): Unit = {
//    makePool(redisHost, redisPort, redisTimeout, maxTotal, maxIdle, minIdle, true, false, 10000)
//  }
//
//  def makePool(redisHost: String, redisPort: Int, redisTimeout: Int,
//               maxTotal: Int, maxIdle: Int, minIdle: Int, testOnBorrow: Boolean,
//               testOnReturn: Boolean, maxWaitMillis: Long): Unit = {
//    if (pool == null) {
//      val poolConfig = new GenericObjectPoolConfig()
//      poolConfig.setMaxTotal(maxTotal)
//      poolConfig.setMaxIdle(maxIdle)
//      poolConfig.setMinIdle(minIdle)
//      poolConfig.setTestOnBorrow(testOnBorrow)
//      poolConfig.setTestOnReturn(testOnReturn)
//      poolConfig.setMaxWaitMillis(maxWaitMillis)
//      pool = new JedisPool(poolConfig, redisHost, redisPort, redisTimeout,"123456")
//
//      val hook = new Thread {
//        override def run: Unit = pool.destroy()
//      }
//      sys.addShutdownHook(hook.run)
//    }
//  }
//
//  def getPool: JedisPool = {
//    assert(pool != null)
//    pool
//  }
//}
